package src.twice;

import java.io.*;

public class FileTest02 {

    public static void main(String[] args) {
        File file = new File("C:\\Users\\22528\\Desktop","javaTest.txt");
        try {
            FileOutputStream out = new FileOutputStream(file);
            byte buy[] = "明日科技 Java部".getBytes();
            out.write(buy);
            out.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        try {
            FileInputStream in = new FileInputStream(file);
            byte byt[] = new byte[1024];
            int len = in.read(byt);
            System.out.println("文件中的信息："+new String(byt,0,len));
            in.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
